package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 巡查任务风险级别枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum PatrolTaskRiskLevel implements BaseEnum {
    LOW("低", "低风险"),
    MEDIUM("中", "中等风险"),
    HIGH("高", "高风险"),
    CRITICAL("紧急", "紧急风险"),
    EXTREME("极端", "极端风险");

    private final String code;
    private final String description;

    PatrolTaskRiskLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PatrolTaskRiskLevel fromCode(String code) {
        for (PatrolTaskRiskLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("无效的风险级别代码: " + code);
    }

    public static PatrolTaskRiskLevel fromDescription(String description) {
        for (PatrolTaskRiskLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("无效的风险级别描述: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}